<template>
  <div ref="chart" class="chart-container"></div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

const props = defineProps({
  data: Array
})

const chart = ref(null)
let myChart

onMounted(() => {
  myChart = echarts.init(chart.value)
  updateChart()
})

const updateChart = () => {
  const option = {
    tooltip: { trigger: 'item' },
    series: [{
      type: 'pie',
      data: props.data,
      radius: ['40%', '70%'],
      itemStyle: {
        borderRadius: 10,
        borderColor: '#fff',
        borderWidth: 2
      }
    }]
  }
  myChart.setOption(option)
}
</script>

<style scoped>
.chart-container {
  height: 300px;
}
</style> 